package com.example.pei.ithinklearnt.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 *
 * Created by Pei on 2018/3/13.
 */

public class OrderDBHelper extends SQLiteOpenHelper {

    private static final int DB_VERSION = 1;

    public static final String TABLE_NEWCOMMENT = "_comments";
    public static final String TABLE_PRIVATECONVERSATION = "_privateconversation";


    public OrderDBHelper(Context context, String DB_NAME){
        super(context, DB_NAME, null, DB_VERSION);
    }

    public OrderDBHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql1="create table if not exists " + TABLE_NEWCOMMENT +
                "(id char(100) not null primary key, fromUsername text, avactor text,content text, time text ,status int ,bcontent text)";
        db.execSQL(sql1);

        String sql2="create table if not exists " + TABLE_PRIVATECONVERSATION +
                "(id char(200) not null primary key,status int )";
        db.execSQL(sql2);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        String sql1 = "DROP TABLE IF EXISTS " + TABLE_NEWCOMMENT;
        String sql2 = "DROP TABLE IF EXISTS " + TABLE_PRIVATECONVERSATION;
        db.execSQL(sql1);
        db.execSQL(sql2);
        onCreate(db);
    }
}
